import 'package:flutter/material.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class BankAgreement extends StatelessWidget {

  final bool consentAgreement;
  final Function onTap;
  BankAgreement({
    required this.consentAgreement,
    required this.onTap
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 36.h,
      padding: EdgeInsets.symmetric(horizontal: 12.w),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: .5,
            color: lineColor
          )
        )
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          InkWellUtil.shakeProofInkWell(Container(
            width: 20.w,
            height: 20.w,
            child: Image.asset(
              consentAgreement ? 'assets/icons/icon_radio_fill.png' : 'assets/icons/icon_radio_line.png',
              width: 20.w,
              height: 20.w,
            ),
          ), () {
            onTap();
          }),
          SizedBox(width: 12.w),
          Container(
            alignment: Alignment.center,
            child: Text.rich(
              TextSpan(
                children: [
                  WidgetSpan(
                    child: Container(
                      alignment: Alignment.topCenter,
                      child: Text(
                        '同意相关',
                        style: TextStyle(
                          color: textBlackColor,
                          fontSize: 12.sp
                        )
                      ),
                    ),
                  ),
                  WidgetSpan(
                    child: InkWellUtil.shakeProofInkWell(Container(
                      alignment: Alignment.topCenter,
                      child: Text(
                        '《快捷支付服务协议》',
                        style: TextStyle(
                          color: mainTextColor,
                          fontSize: 12.sp
                        )
                      ),
                    ), () {
                      Get.toNamed(
                        '${AppRouters.COMMON_PAGE}${AppRouters.ARTICLE_DETAIL_PAGE}',
                        arguments: {
                          'articleId': 11,
                          'title': '快捷支付服务协议'
                        }
                      );
                    }),
                  ),
                ]
              )
            ),
          ),
        ],
      ),
    );
  }
  
}